version 12
set more off

*      Flores & Nooruddin 'Post-Conflict Elections' JOP 2012 Replication Code

   ****************************************************************
   ***                                                          ***
   ***  This file contains the code to generate all tables in   ***
   ***  Flores & Nooruddin, "The Effect of Elections on         ***
   ***  Postconflict Peace and Reconstruction." Journal of 		***
   ***  Politics, vol. 74, no. 2, pp. 558-570.
   ***															***
   ****************************************************************


/* This file is intended for use with the data file 
"Flores&Nooruddin.JOP2012.Replication data file.dta". 
Please communicate all errors to teflores@gmail.com and 
nooruddin.3@osu.edu. */

***************************************************************************
***************************************************************************
***************************************************************************
***************************************************************************

** TABLE 2 (PAGE 564): POST-CONFLICT ELECTIONS WORK DIFFERENTLY IN NEW DEMOCRACIES

*BASELINE MODEL
*Recovery
stset recover_time2, f(recover2==1) exit(exit_year2==1) id(testnewid_lag)
streg prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag /*
*/ recovery_num2 ln_unpkos wb_dummy elec_recperiod /*
*/ if west==0, dist(lnormal) nolog cluster(id) 
estimates store ln_recover1

test victory_lag=peace_agreement_lag

*Recurrence
stset recover_time2, f(recur2==1) exit(exit_year2==1) id(testnewid_lag)
streg prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag /*
*/ recovery_num2 ln_unpkos wb_dummy elec_recperiod /*
*/ if west==0, dist(lnormal) nolog cluster(id) 
estimates store ln_recur1

test victory_lag=peace_agreement_lag


* FULL MODEL
*Recovery
stset recover_time2, f(recover2==1) exit(exit_year2==1) id(testnewid_lag)
streg prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag /*
*/ recovery_num2 ln_unpkos wb_dummy /*
*/ olddem newdem elec_firstyr elec_secondyr elec_thirdyrplus /*
*/ elec_firstyrXolddem elec_secondyrXolddem elec_thirdyrplusXolddem /*
*/ elec_firstyrXnewdem elec_secondyrXnewdem elec_thirdyrplusXnewdem /*
*/ if west==0, dist(lnormal) nolog cluster(id) 
estimates store ln_recover2


*Recurrence
stset recover_time2, f(recur2==1) exit(exit_year2==1) id(testnewid_lag)
streg prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag /*
*/ recovery_num2 ln_unpkos wb_dummy /*
*/ olddem newdem  elec_firstyr elec_secondyr elec_thirdyrplus /*
*/ elec_firstyrXolddem elec_secondyrXolddem elec_thirdyrplusXolddem /*
*/ elec_firstyrXnewdem elec_secondyrXnewdem elec_thirdyrplusXnewdem /*
*/ if west==0, dist(lnormal) nolog cluster(id) 
estimates store ln_recur2


***************************************************************************
***************************************************************************
***************************************************************************
***************************************************************************

** COMMANDS FOR RESULTS REPORTED IN DISCUSSION (PAGES 564-567)
*Summarize command for substantive effects
summ prewar_lngdppc2 ln_oda_constant_new cw_duration_lag damage victory_lag ln_unpkos if e(sample)

*STATISTAL SIGNIFICANCE TESTS
*Does the timing of elections in est. democracies matter? 
*Short answer: from first to second matters; delaying to 3rd doesn't.

*Is the effect of elections statistically significant in est. democracies?
*Short answer: yes.
test (elec_firstyr+elec_firstyrXolddem)=0
test (elec_secondyr+elec_secondyrXolddem)=0
test (elec_thirdyrplus+elec_thirdyrplusXolddem)=0

*Is the effect of elections statistically significant in new democracies?
*Short answer: yes
test elec_firstyr+elec_firstyrXnewdem=0
test elec_secondyr+elec_secondyrXnewdem=0
test elec_thirdyrplus+elec_thirdyrplusXnewdem=0

*H1: Do elections have different effects in new democracies versus old democracies?
*Comparing the same year
*Short answer: yes
test elec_firstyrXnewdem=elec_firstyrXolddem
test elec_secondyrXnewdem=elec_secondyrXolddem
test elec_thirdyrplusXnewdem=elec_thirdyrplusXolddem

*H1: Do elections have different effects in new democracies versus old democracies?
*Comparing earlier elections in est. demos to later elections in new demos.

test elec_secondyrXnewdem=elec_firstyrXolddem

test elec_thirdyrplusXnewdem=elec_firstyrXolddem
test elec_thirdyrplusXnewdem=elec_secondyrXolddem

*H2: Does the timing of elections in non-democracies matter?
*Short answer: no.
test elec_firstyr=elec_secondyr 
test elec_firstyr=elec_thirdyrplus 
test elec_secondyr=elec_thirdyrplus 

*H2: Does the timing of elections in old democracies matter?
*Short answer: yes (don't have it in the first yr)
test (elec_firstyr+elec_firstyrXolddem)=(elec_secondyr+elec_secondyrXolddem)
test (elec_firstyr+elec_firstyrXolddem)=(elec_thirdyrplus+elec_thirdyrplusXolddem)
test (elec_secondyr+elec_secondyrXolddem)=(elec_thirdyrplus+elec_thirdyrplusXolddem)

*H2: Does the timing of elections in new democracies matter?
*Short answer: yes (wait until at least the 3rd)
test (elec_firstyr+elec_firstyrXnewdem)=(elec_secondyr+elec_secondyrXnewdem)
test (elec_firstyr+elec_firstyrXnewdem)=(elec_thirdyrplus+elec_thirdyrplusXnewdem)
test (elec_secondyr+elec_secondyrXnewdem)=(elec_thirdyrplus+elec_thirdyrplusXnewdem)


*Mean values of key variables for the substantive comparisons.
summarize prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag recovery_num2 ln_unpkos wb_dummy if e(sample)


***************************************************************************
***************************************************************************
***************************************************************************
***************************************************************************

** ROBUSTNESS AND NON-RANDOM SELECTION (PAGE 567 AND WEB APPENDIX)

*ARE COUNTRIES THAT HOLD ELECTIONS POORER?
*Pre-war GDPpc
ttest prewar_lngdppc2 if recover_time2==1, by(elec_recperiod)
ttest prewar_lngdppc2 if recover_time2==1 & elec_recperiod==1, by(elec_firstyr)
ttest prewar_lngdppc2 if recover_time2==1 & elec_recperiod==1, by(elec_secondyr)
ttest prewar_lngdppc2 if recover_time2==1 & elec_recperiod==1, by(elec_thirdyrplus)

*Election vs. no election
ttest prewar_lngdppc2 if recover_time2==1, by(elec_recperiod)

*First year vs. no election
ttest prewar_lngdppc2 if elec_recperiod~=. & recover_time2==1 & (elec_recperiod==0|elec_firstyr==1), by(elec_firstyr)

*Second year vs. no election
ttest prewar_lngdppc2 if elec_recperiod~=. & recover_time2==1 & (elec_recperiod==0|elec_secondyr==1), by(elec_secondyr)

*Third year vs. no election
ttest prewar_lngdppc2 if elec_recperiod~=. & recover_time2==1 & (elec_recperiod==0|elec_thirdyrplus==1), by(elec_thirdyrplus)

*First year vs. second year
ttest prewar_lngdppc2 if recover_time2==1 & elec_recperiod~=.& (elec_firstyr==1|elec_secondyr==1), by(elec_secondyr)

*First year vs. third year
ttest prewar_lngdppc2 if  recover_time2==1 & elec_recperiod~=.& (elec_firstyr==1|elec_thirdyrplus==1), by(elec_thirdyrplus)

*Second year vs. third year
ttest prewar_lngdppc2 if elec_recperiod~=. & recover_time2==1 & (elec_secondyr==1|elec_thirdyrplus==1), by(elec_thirdyrplus)


*ECONOMIC DAMAGE
ttest damage if elec_recperiod~=.&elec_recperiod==0|elec_firstyr==1, by(elec_firstyr)
ttest damage if elec_recperiod~=.&elec_recperiod==0|elec_secondyr==1, by(elec_secondyr)
ttest damage if elec_recperiod~=.&elec_firstyr==1|elec_secondyr==1, by(elec_secondyr)
ttest damage if elec_recperiod~=.&elec_recperiod==0|elec_thirdyrplus==1, by(elec_thirdyrplus)
ttest damage if elec_recperiod~=.&elec_firstyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)
ttest damage if elec_recperiod~=.&elec_secondyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*POST-CONFLICT GROWTH
ttest gdppc_growth if elec_recperiod~=.&elec_recperiod==0|elec_firstyr==1, by(elec_firstyr)
ttest gdppc_growth if elec_recperiod~=.&elec_recperiod==0|elec_secondyr==1, by(elec_secondyr)
ttest gdppc_growth if recover_time2==1&elec_recperiod~=.&elec_firstyr==1|elec_secondyr==1, by(elec_secondyr)
ttest gdppc_growth if elec_recperiod~=.&elec_recperiod==0|elec_thirdyrplus==1, by(elec_thirdyrplus)
ttest gdppc_growth if elec_recperiod~=.&elec_firstyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)
ttest gdppc_growth if elec_recperiod~=.&elec_secondyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*CIM
*Election vs. no election
ttest cim_cim, by(elec_recperiod)
ttest cim_cim if recover_time2==1, by(elec_recperiod)

*First year vs. no election
ttest cim_cim if elec_recperiod~=.&elec_recperiod==0|elec_firstyr==1, by(elec_firstyr)

*Second year vs. no election
ttest cim_cim if elec_recperiod~=.&elec_recperiod==0|elec_secondyr==1, by(elec_secondyr)

*Third year vs. no election
ttest cim_cim if elec_recperiod~=.&elec_recperiod==0|elec_thirdyrplus==1, by(elec_thirdyrplus)

*First year vs. second year
ttest cim_cim if recover_time2==1&elec_recperiod~=.&elec_firstyr==1|elec_secondyr==1, by(elec_secondyr)

*First year vs. third year
ttest cim_cim if recover_time2==1&elec_recperiod~=.&elec_firstyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*Second year vs. third year
ttest cim_cim if elec_recperiod~=.&elec_secondyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)



*FDI
*Election vs. no election
ttest wdi61, by(elec_recperiod)
ttest wdi61 if recover_time2==1, by(elec_recperiod)

*No election vs. first year
ttest wdi61 if elec_recperiod~=.&elec_recperiod==0|elec_firstyr==1, by(elec_firstyr)

*No election vs. second year
ttest wdi61 if elec_recperiod~=.&elec_recperiod==0|elec_secondyr==1, by(elec_secondyr)

*No election vs. third year
ttest wdi61 if elec_recperiod~=.&elec_recperiod==0|elec_thirdyrplus==1, by(elec_thirdyrplus)

*First vs. second year
ttest wdi61 if recover_time2==1&elec_recperiod~=.&elec_firstyr==1|elec_secondyr==1, by(elec_secondyr)

*First vs. third year
ttest wdi61 if recover_time2==1&elec_recperiod~=.&elec_firstyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*Second vs. third year
ttest wdi61 if elec_recperiod~=.&elec_secondyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*ODA
ttest oda_constant_percap, by(elec_recperiod)
ttest oda_constant_percap if recover_time2==1, by(elec_recperiod)

*No election vs. first year
ttest oda_constant_percap if elec_recperiod~=.&elec_recperiod==0|elec_firstyr==1, by(elec_firstyr)

*No election vs. second year
ttest oda_constant_percap if elec_recperiod~=.&elec_recperiod==0|elec_secondyr==1, by(elec_secondyr)

*No election vs. third year
ttest oda_constant_percap if elec_recperiod~=.&elec_recperiod==0|elec_thirdyrplus==1, by(elec_thirdyrplus)

*First year vs. second year
ttest oda_constant_percap if elec_recperiod~=.&elec_firstyr==1|elec_secondyr==1, by(elec_secondyr)

*First year vs. third year
ttest oda_constant_percap if elec_recperiod~=.&elec_firstyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*Second year vs. third year
ttest oda_constant_percap if elec_recperiod~=.&elec_secondyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*World Bank aid
ttest wb_commit_total_percap, by(elec_recperiod)
ttest wb_commit_total_percap if recover_time2==1, by(elec_recperiod)

*No election vs. first year
ttest wb_commit_total_percap if elec_recperiod~=.&elec_recperiod==0|elec_firstyr==1, by(elec_firstyr)

*No election vs. second year
ttest wb_commit_total_percap if elec_recperiod~=.&elec_recperiod==0|elec_secondyr==1, by(elec_secondyr)

*No election vs. third year
ttest wb_commit_total_percap if elec_recperiod~=.&elec_recperiod==0|elec_thirdyrplus==1, by(elec_thirdyrplus)

*First year vs. second year
ttest wb_commit_total_percap if elec_recperiod~=.&elec_firstyr==1|elec_secondyr==1, by(elec_secondyr)

*First year vs. third year
ttest wb_commit_total_percap if elec_recperiod~=.&elec_firstyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*Second year vs. third year
ttest wb_commit_total_percap if elec_recperiod~=.&elec_secondyr==1|elec_thirdyrplus==1, by(elec_thirdyrplus)

*ARE ELECTIONS MORE LIKELY HELD AFTER PEACE AGREEMENTS?	
tab victory_lag elec_recperiod  if recover_time2==1 , row
tab peace_agreement_lag elec_recperiod  if recover_time2==1 , row
tab ceasefire_lag elec_recperiod  if recover_time2==1 , row
tab low_activity_lag elec_recperiod  if recover_time2==1 , row

tab victory_lag elec_firstyr  if recover_time2==1 & elec_recperiod==1 , row
tab peace_agreement_lag elec_firstyr  if recover_time2==1 & elec_recperiod==1, row
tab ceasefire_lag elec_firstyr  if recover_time2==1 & elec_recperiod==1, row
tab low_activity_lag elec_firstyr  if recover_time2==1 & elec_recperiod==1, row

tab victory_lag elec_thirdyrplus  if recover_time2==1 & elec_recperiod==1, row
tab peace_agreement_lag elec_thirdyrplus  if recover_time2==1 & elec_recperiod==1, row
tab ceasefire_lag elec_thirdyrplus  if recover_time2==1 & elec_recperiod==1, row
tab low_activity_lag elec_thirdyrplus  if recover_time2==1 & elec_recperiod==1, row


*POST-COLD WAR MODEL
*Recovery
stset recover_time2, f(recover2==1) exit(exit_year2==1) id(testnewid_lag)
streg prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag /*
*/ recovery_num2 ln_unpkos wb_dummy /*
*/ olddem newdem elec_firstyr elec_secondyr elec_thirdyrplus /*
*/ elec_firstyrXolddem elec_secondyrXolddem elec_thirdyrplusXolddem /*
*/ elec_firstyrXnewdem elec_secondyrXnewdem elec_thirdyrplusXnewdem /*
*/ if west==0 & year>=1990, dist(lnormal) nolog cluster(id) 
estimates store ln_recover2_post1989


*Recurrence
stset recover_time2, f(recur2==1) exit(exit_year2==1) id(testnewid_lag)
streg prewar_lngdppc2 ln_oda_constant_new issue_territory_lag cw_duration_lag damage victory_lag peace_agreement_lag /*
*/ recovery_num2 ln_unpkos wb_dummy /*
*/ olddem newdem  elec_firstyr elec_secondyr elec_thirdyrplus /*
*/ elec_firstyrXolddem elec_secondyrXolddem elec_thirdyrplusXolddem /*
*/ elec_firstyrXnewdem elec_secondyrXnewdem elec_thirdyrplusXnewdem /*
*/ if west==0 & year>=1990, dist(lnormal) nolog cluster(id) 
estimates store ln_recur2_post1989
